package com.sykj.util.wepay.websocket;

import com.sykj.util.wepay.PayCommonUtil;
import com.sykj.util.wepay.ZxingUtil;
import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
import sun.misc.BASE64Encoder;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: BeautyClub
 * @description:
 * @author: qiaoli
 * @create: 2020-08-11 11:03
 */
public class CreateImg {

    public static String zhuan(String result) throws  Exception{
        BufferedImage image = ZxingUtil.createImage(result, 300, 300);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ImageIO.write(image, "png", outputStream);
        BASE64Encoder encoder = new BASE64Encoder();
        String base64 = encoder.encodeBuffer(outputStream.toByteArray()).trim();
        base64 = base64.replaceAll("\n", "").replaceAll("\r", "");
        return base64;
    }
}
